<?php
	include "../../inc/log/admin_session1.php";
	// include "../../inc/data/connAdmin.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<?php 
	include "../../inc/data/connAdmin.php";
	$depNname = $_POST["depNew"];
	// 1903010328 检查重名
	$sql = "select depname from mamx_dep where depname = ?";
	$stmtA = $conn->prepare($sql);
	$stmtA->bind_param("s",$depNname);
	$stmtA->execute();
	$stmtA->bind_result($depName);
	$stmtA->store_result();
	$stmtA->fetch();
	?>
<!-- 1903010328 检查是否重名 -->
	<?php
	if ($stmtA->num_rows > 0) {
		?>
		<script type="text/javascript">
		alert('添加失败！该名称已存在！');
		location = "depAdd.php";	
		</script>
		<?php	
	}else{
		$sql = "insert into mamx_dep
		value ('$depNname')";
		$stmt = $conn->prepare($sql);
		$stmt->execute();
		?>
		<script type="text/javascript">
		alert('添加成功！');
		location = "depAdmin.php";	
		</script>
		<?php
	}
	 ?>
</body>
</html>